package com.iheima.branch;

import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        System.out.println("请输入一个数字:");
        Scanner sc = new Scanner(System.in);
        int num=sc.nextInt();
        System.out.println("该数字的质数个数为：" + test3(num));
    }
    public static int test3(int num) {
        int count = 0;
        for (int i = 2; i <= num; i++) {
            boolean flag = true;
            for (int j = 2; j <=Math.sqrt(i); j++) {
                if (i % j == 0) {
                    flag = false;
                    break;
                }
            }
            if(flag)count++;
        }
        return count;
    }
}
